package com.csit.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="T_CustomerCard")
public class CustomerCard implements Serializable {

	private static final long serialVersionUID = -6499598340873713905L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer cardID;
	
	@Column(length=50,unique=true)
	private String cardCode;
	
	@Column(precision=2)
	private Double amount;
	
	private Integer score;
	
	@Column(length=1024)
	private String note;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="customerID")
	private Customer customer;

	public Integer getCardID() {
		return cardID;
	}

	public void setCardID(Integer cardID) {
		this.cardID = cardID;
	}

	public String getCardCode() {
		return cardCode;
	}

	public void setCardCode(String cardCode) {
		this.cardCode = cardCode;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}
	
	@Transient
	public Integer getCustomerID(){
		if(customer==null){
			return null;
		}
		return customer.getCustomerID();
	}
	
	@Transient
	public String getCustomerCode(){
		if(customer==null){
			return null;
		}
		return customer.getCustomerCode();
	}
	
	@Transient
	public String getCustomerName(){
		if(customer==null){
			return null;
		}
		return customer.getCustomerName();
	}
	
}
